#ifndef __MID_PWM_H
#define __MID_PWM_H

#include "ac780x_pwm.h"
#include "ac780x_pwm_reg.h"
#include "ac780x_gpio.h"
#include "mid_i2c.h"
#include <stdio.h>
#include <string.h>

#define PWM0_FREQ      (10000UL)                                          /* PWM0 frequency, here set to 20KHz */
#define PWM0_CLK_PSC   (1UL)                                              /* PWM0 clock frequency division, here set 1 frequency division */
#define PWM0_MAX_VALUE (g_periphAPBClock / PWM0_CLK_PSC / PWM0_FREQ / 2UL)/* PWM0 counter maximum count value */

#define PWM0_CH3_DUTY  (12UL)                                             /* PWM0 channel 3 duty cycle, here set to 60% */
#define PWM0_CH3_VALUE (PWM0_CH3_DUTY * PWM0_MAX_VALUE / 100UL)           /* PWM0 channel 3 match value */

//#define PWM2_FREQ      100//(20000UL)                                     /* PWM2 frequency, here set to 20KHz */
//#define PWM2_CLK_PSC   (20UL)                                              /* PWM2 clock frequency division, here set 1 frequency division */
//#define PWM2_MAX_VALUE (g_periphAPBClock / PWM2_CLK_PSC / PWM2_FREQ / 2UL)/* PWM2 counter maximum count value */


#define PWM1_FREQ      (100UL)                                           /* PWM1 frequency, here set to 2KHz */
#define PWM1_CLK_PSC   (10UL)                                              /* PWM1 clock frequency division, here set 1 frequency division */
#define PWM1_MAX_VALUE (g_periphAPBClock / PWM1_CLK_PSC / PWM1_FREQ)      /* PWM1 counter maximum count value */

#define PWM1_CH3_DUTY  (50UL)                                             /* PWM1 channel 1 duty cycle, here set to 80% */
#define PWM1_CH3_VALUE (PWM1_CH3_DUTY * PWM1_MAX_VALUE / 100UL)           /* PWM1 channel 1 match value */


#define PWM2_FREQ      (2000UL)                                          /* PWM2 frequency, here set to 20KHz */
#define PWM2_CLK_PSC   (1UL)                                              /* PWM2 clock frequency division, here set 1 frequency division */
#define PWM2_MAX_VALUE (g_periphAPBClock / PWM2_CLK_PSC / PWM2_FREQ)/* PWM2 counter maximum count value */

#define PWM2_CH3_DUTY  (50UL)                                             /* PWM2 channel 3 duty cycle, here set to 60% */
#define PWM2_CH3_VALUE (PWM2_CH3_DUTY * PWM2_MAX_VALUE / 100UL)           /* PWM2 channel 3 match value */

#define LC_MIRROR_ON	PWM2_OutputCombine_Init()
#define LC_MIRROR_OFF	PWM_DeInit(PWM2)	

extern void Set_BlackLight_PwmDuty(uint8_t Duty);
extern void PWM0_OutputIndependent_Init(void);
extern void PWM2_OutputCombine_Init(void);
extern void LC_PWM_OutputIndependent_Init(void);
#endif
